import React from 'react'
import { Route, useHistory } from 'react-router-dom'
import SearchA from './SearchA'
import SearchB from './SearchB'

export default function Search() {
  const history = useHistory()

  const jumpA = () => {
    history.push('/Search/a')
  }
  const jumpB = () => {
    history.push('/Search/b')
  }
  return (
    <div>
      Search 我是搜索页
      <button onClick={jumpA}>A</button>
      <button onClick={jumpB}>B</button>
      {/* 子路由必须以父路由开头, 为了保证先匹配父路由 */}
      <Route path="/Search/a" component={SearchA}></Route>
      <Route path="/Search/b" component={SearchB}></Route>
    </div>
  )
}
